<?php
/**
 *  NevuxBB - Free Forum Software
 *  Copyright (C) 2008, 2010 NevuxBB (No one specific author)*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Header File
 * File: header.php
 * Purpose: The begining part of the forum pages
 * Todo: Finish writing it
 *
 */

// is this the index?
if(basename($_SERVER['PHP_SELF']) == 'index.php') {
	// run count, cleanup and get statistics
	$online_stats = ForumSettings::getTotalOnline(3);
} else {
	// run the count and cleanup only
	$online_stats = ForumSettings::getTotalOnline(4);
}


// is debug enabled in this system?
if(GlobalSettings::getSetting('debug_enabled') == 1) {
	// debuging is enabled
	$core_template_system->setvar('debug_enabled', true);
	
	// we need some special functions
	include(BASE_PATH . '/system/functions/file_functions.php');
}

// build the header
$core_template_system->newTemplate(BASE_PATH . '/templates/' . ForumSettings::getCurrentTemplate() . '/header.html');

// are we logged in?
if(CoreUserSystem::isLoggedIn()) {
	// set the username
	$core_template_system->setvar('loggedin_username', CoreUserSystem::getUsername());
	
	// are we can admin?
	if(CoreUserSystem::getUserlevel() == 3) {
		$core_template_system->setvar('admin_acp_link', true);
	}
}

// set some template variables
$core_template_system->setvar(array('is_logged_in'        => CoreUserSystem::isLoggedIn(),
									'site_domain'         => 'http://' . GlobalSettings::getSetting('forum_domain'),
									'acp_link'            => $core_lang_system->get_var('ACP_LINK', 1),
									'global_sitename'     => GlobalSettings::getSetting('site_name'),
									'index_location'      => urlSystem::navParts(1),
									'memberlist_location' => urlSystem::viewURL(4, ' '),
									'search_location'     => urlSystem::navParts(2),
									'rules_location'      => urlSystem::navParts(3),
									'register_location'   => urlSystem::navParts(5),
									'login_location'      => urlSystem::navParts(6),
									'logout_location'     => urlSystem::navParts(4),
									'faqs_location'       => urlSystem::navParts(8),
									'calendar_location'   => urlSystem::navParts(9),
									'board_i'             => $core_lang_system->get_var('B_INDEX', 4),
									'members'             => $core_lang_system->get_var('MEMBERS', 4),
									'search' 		      => $core_lang_system->get_var('SEARCH', 4),
									'rules'			      => $core_lang_system->get_var('RULES', 4)));
?>